package com.example.greedysnake.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.greedysnake.R;
import com.example.greedysnake.datas.SnakeGamingData;

public class SnakeScoreActivity extends AppCompatActivity {

    TextView textViewScore;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_snake_score);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        textViewScore = findViewById(R.id.tv_snake_score);
        SharedPreferences sharedPreferences = getSharedPreferences(SnakeGamingData.KEY_SHP_FILE_NAME, MODE_PRIVATE);
        textViewScore.setText(String.valueOf(sharedPreferences.getInt(SnakeGamingData.KEY_SHP_SCORE, 0)));

    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == android.R.id.home){
            finish();
        }
        return super.onOptionsItemSelected(item);
    }
}